package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TbSt;
import com.ruoyi.system.service.ITbStService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 题目管理Controller
 * 
 * @author 朱欢乐
 * @date 2025-10-25
 */
@RestController
@RequestMapping("/st/st")
public class TbStController extends BaseController
{
    @Autowired
    private ITbStService tbStService;

    /**
     * 查询题目管理列表
     */
    @PreAuthorize("@ss.hasPermi('st:st:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbSt tbSt)
    {
        startPage();
        List<TbSt> list = tbStService.selectTbStList(tbSt);
        return getDataTable(list);
    }

    /**
     * 导出题目管理列表
     */
    @PreAuthorize("@ss.hasPermi('st:st:export')")
    @Log(title = "题目管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbSt tbSt)
    {
        List<TbSt> list = tbStService.selectTbStList(tbSt);
        ExcelUtil<TbSt> util = new ExcelUtil<TbSt>(TbSt.class);
        util.exportExcel(response, list, "题目管理数据");
    }

    /**
     * 获取题目管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('st:st:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbStService.selectTbStById(id));
    }

    /**
     * 新增题目管理
     */
    @PreAuthorize("@ss.hasPermi('st:st:add')")
    @Log(title = "题目管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbSt tbSt)
    {
        return toAjax(tbStService.insertTbSt(tbSt));
    }

    /**
     * 修改题目管理
     */
    @PreAuthorize("@ss.hasPermi('st:st:edit')")
    @Log(title = "题目管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbSt tbSt)
    {
        return toAjax(tbStService.updateTbSt(tbSt));
    }

    /**
     * 删除题目管理
     */
    @PreAuthorize("@ss.hasPermi('st:st:remove')")
    @Log(title = "题目管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbStService.deleteTbStByIds(ids));
    }
}
